﻿namespace MicroCloud.Authorization
{
    /// <summary>
    /// 实体信息处理器接口
    /// </summary>
    public interface IEntityInfoHandler
    {
        #region 方法
        /// <summary>
        /// 从程序集中刷新实体信息
        /// <para>实现了 <see cref="IEntity{TKey}"/> 接口的实体类</para>
        /// </summary>
        void Initialize();
        
        /// <summary>
        /// 查找指定实体类型的实体信息
        /// </summary>
        /// <param name="type">实体类型</param>
        /// <returns>实体信息</returns>
        IEntityInfo GetEntityInfo(Type type);

        /// <summary>
        /// 查找指定实体类型的实体信息
        /// </summary>
        /// <typeparam name="TEntity">实体类型</typeparam>
        /// <typeparam name="TKey">实体主键类型</typeparam>
        /// <returns>实体信息</returns>
        IEntityInfo GetEntityInfo<TEntity, TKey>() where TEntity : IEntity<TKey> where TKey : IEquatable<TKey>;
    
        /// <summary>
        /// 刷新实体信息缓存
        /// </summary>
        void RefreshCache();

        /// <summary>
        /// 查找指定名称的实体类型
        /// </summary>
        /// <param name="typeName">类型名称</param>
        /// <returns>实体类型</returns>
        Type GetEntityType(string typeName);

        #endregion

    }

}
